#!/bin/bash -e

function info() {
    echo Usage: `basename $0` [-p out_prefix -s out_suffix] t.bam pon_site_only.vcf
    exit 1
}

while getopts ":p:s:t:i:n:" opt; do
    case $opt in
        p) out_prefix=$OPTARG;;
        s) out_suffix=$OPTARG;;
        t) threads=$OPTARG;;
        i) interval=$OPTARG;;
        n) normal=$OPTARG;;
        ?) info;;
    esac
done
shift $(($OPTIND - 1))

if [ $# -lt 1 ]; then info; fi

. $var || :

test -n "$interval" && interval="-L $interval"
test -n "$normal" && normal="-I:normal $normal"

$java_run/gatk38 \
-T MuTect2 \
-R $ref_genome $interval \
-I:tumor $1 $normal\
--cosmic $cosmic \
--normal_panel $2 \
-dt NONE \
--output_mode EMIT_VARIANTS_ONLY \
-newQual \
-maxReadsInRegionPerSample 10000 \
-stand_call_conf 5 \
-nct $nct \
--kmerSize 10 \
--kmerSize 15 \
--kmerSize 20 \
--kmerSize 25 \
-o $out_prefix.mutect2.vcf.gz
# --dbsnp $dbsnp \


# gzcat mutect2.vcf.gz

echo mutect2 generate bam
$java_run/gatk38 \
-T MuTect2 \
-R $ref_genome \
-I:tumor $1 $normal \
--cosmic $cosmic \
--normal_panel $2 \
-maxReadsInRegionPerSample 10000 \
--disableOptimizations \
--dontTrimActiveRegions --forceActive \
-L $out_prefix.mutect2.vcf.gz \
-ip 500 \
-stand_call_conf 5 \
-bamout $out_prefix.m2.bam
# --dbsnp $dbsnp \


. $cmd_done

